package com.gyhoo.firstbootdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyMvcConfiguration implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //项目首页
        registry.addViewController("/").setViewName("login");
        //首页跳转
        registry.addViewController("/main.html").setViewName("main");
        //跳转到登录页面
        registry.addViewController("/login.html").setViewName("login");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyIntercepteor())
                .addPathPatterns("/**").excludePathPatterns("/","/login.html","/login",
                "/assets/*","/css/*","/js/*");
    }

    //添加地域信息解析器
    @Bean
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }

}
